<%= render(:partial => "shared/flash_message") %>
<%= render :partial => "shared/config_save_actions" -%>

<%= form_for(@material, :as => :material, :url => admin_pluggable_scm_choose_existing_path, :html => {"novalidate"=> "novalidate", :id=> "material_form", :name=> "material_form", :method => "POST", :onsubmit => "return AjaxForm.jquery_ajax_submit(this);", :class => "popup_form"}) do |f| %>
    <%= md5_field %>

    <div class="form_content">
        <%= render :partial => "admin/shared/global_errors.html", :locals => {:scope => {}} -%>
        <div id="material">
            <%= render :partial => 'shared/form_required_message.html', :locals => {:scope => {}} %>

            <%- if @scms.empty? -%>
                <p class="warnings">No SCMs found. Please add a SCM first.</p>
            <%- end -%>

            <div class="fieldset">
                <label for="material_<%= com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig::SCM_ID -%>">Select SCM</label>
                <%= f.select com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig::SCM_ID, @scms.collect {|scm| [scm.getName(), scm.getId()]}, {}, {:id => "scm_id"} -%>
                <%= error_message_on(@material, com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig::SCM_ID, :css_class => "form_error") %>
            </div>

            <h3>Destination Directory</h3>
            <div class="fieldset">
                <%= f.text_field(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig::FOLDER, {:class => "form_input", :id => nil}) -%>
                <%= error_message_on(@material, com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig::FOLDER, :css_class => "form_error") %>
            </div>

            <h3>Blacklist</h3>
            <div class="fieldset">
                <label>Enter the paths to be excluded. Separate multiple entries with a comma.</label>
                <% @material.filter().each do |ignored_file|
                  error = ignored_file.errors().on(com.thoughtworks.go.config.materials.IgnoredFiles::PATTERN)
                  if error
                    @material.errors().add(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig::FILTER, error)
                  end
                end %>

                <%= f.text_area(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig::FILTER, {:class => "form_input", :id => nil, :rows => 2}) -%>
                <%= error_message_on(@material, com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig::FILTER, :css_class => "form_error") %>
                <div class="clear"></div>
            </div>
        </div>
    </div>
    <%= render :partial => "shared/form_buttons.html", :locals => {:scope => {:submit_label => 'SAVE'}} %>
    <%= render :partial => 'shared/convert_tool_tips.html' %>
<% end %>
